﻿namespace StochasticSimulation.ChemicalReaction.ReactionGraph

open StochasticSimulation.ChemicalReaction.ChemicalReaction

//type ReactionGraph ( reactions:seq<Reaction> ) =
//    
////    new(AddReaction : Reaction,  Graph : ReactionGraph ) = 
////        raise ( System.NotImplementedException() )
//
//    member this.Affects( r : Reaction ) =
//        false
//
//    member this.Depends( r : Reaction ) =
//        false


type Node<'T> =
    int (* node identifier *) *
    'T (* node data *)
 
type Edge<'T> =
    Node<'T> * Node<'T> (* from * to *)
 
type Connection<'T> =
    Node<'T> * Edge<'T> list

 
type Graph( reactions : Reaction list ) =
    let inputNodes : Node<Reaction> list =
        reactions |> List.mapi (fun i nd -> (i,nd) )
//    let converter a =
//        List.pick (fun n -> if snd n = a then Some(n) else None) inputNodes
    let toEdge sink source : Edge<Reaction>=
        (sink,source)
    //let edges = List.map (fun r -> toEdge(r, List.filter (fun rr -> r.Affects rr ) reactions )) reactions
            //|> List.map (fun a -> toEdge 
//    let connections
//            List.map (fun n 
            //|> List.map ( fun (node,raw) -> (node, Array.map (converter) (raw.Split(',')) ) )
            //|> List.map ( fun (node,edges) -> (node, Set.toList (Set.intersect (Set.ofList inputNodes) (Set.ofArray edges)) |> List.map (toEdge node) ) )
    
    static member toEdges(reactions:Reaction list) : Edge<Reaction> list = 
        []

    member this.Affects( r : 'V ) =
        false

    member this.Depends( r : 'V ) =
        false 
 